package org.example;

public class ThreadInterruptDemo {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(){
            @Override
            public void run(){
                while (true)
                    System.out.println(isInterrupted());
//                while(!isInterrupted())
//                    System.out.println("hello");
            }
        };
        thread.start();
        Thread.sleep(1000);
        thread.interrupt();//调用了Thread.interrupt()后，Thread.isInterrupted就为true了
    }
}
